#define HELPER_COMPILATION

#include "enbhelper.h"

bool	bInitialized = false;

DWORD	ADDR_HOURS=0;
DWORD	ADDR_MINUTES=0;



bool HELPER_API getTime(float& time)
{
	if (!bInitialized) return false;
	BYTE	hours = *(BYTE*)ADDR_HOURS;
	BYTE	minutes = *(BYTE*)ADDR_MINUTES;
	time = ((float)hours) + (((float)minutes)/60.0f);
	return true;
}

bool HELPER_API getCustomShaderConstants1(float *vectors)
{
	if (!bInitialized) return false;
	if (!vectors) return false;
	//TODO: Add here whatever you want to get from game and then sent to shaders of ENBSeries
	//WARNING! vectors are 4 floats, 8 vectors total, which are 32 floats
	for (DWORD i=0; i<32; i++)
	{
		vectors[i] = 0.0f;
	}
	return false; //always fail in this test
	//return true;
}



bool HELPER_API helperInit(HelperFuncs& funcs)
{
	if (bInitialized) return false;

	bool	isvalid = false;
	//GTASA 1.0 US
	DWORD	verify = *(DWORD*)(((DWORD)GetModuleHandle(NULL)) + 0x000CDE70);
	if (verify == 0xC933C18B)
	{
		isvalid = true;

		ADDR_HOURS = 0x00B70153;
		ADDR_MINUTES = 0x00B70152;
	}


	funcs.version = HELPER_VER;
	funcs.getTime = getTime;

	bInitialized = isvalid;
	return isvalid;
}



bool HELPER_API helperUninit()
{
	if (!bInitialized) return false;

	bInitialized = false;
	return true;
}



BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved)
{
    return TRUE;
}